<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!--********************************************************************
* 该示例需要引入 
* G6 (https://github.com/antvis/G6)
*********************************************************************-->
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
    <title data-i18n="resources.title_l7_turin_road_map"></title>
    <script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
    <style>
      body {
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100vh;
        overflow: hidden;
      }
      #map {
        width: 100%;
        height: 100%;
      }
    </style>
  </head>

  <body>
    <div id="map"></div>
    <script type="text/javascript" include="mapbox-gl-enhance,L7" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
    <script type="text/javascript">
      var host = window.isLocal ? window.server : 'https://iserver.supermap.io';
      var attribution =
        "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
        " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
        " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";

      var tileURL = host + '/iserver/services/map-china/rest/maps/ChinaDark/zxyTileImage.png?z={z}&x={x}&y={y}';
      var map = new mapboxgl.Map({
        container: 'map',
        style: {
          version: 8,
          sources: {
            'raster-tiles': {
              attribution: attribution,
              type: 'raster',
              tiles: [tileURL],
              tileSize: 256
            }
          },
          layers: [
            {
              id: 'simple-tiles',
              type: 'raster',
              source: 'raster-tiles',
              minzoom: 0,
              maxzoom: 22
            }
          ]
        },
        center: [7.65, 45.053],
        zoom: 12
      });

      map.on('load', function () {
        fetch('https://iclient.supermap.io/web/data/L7/98a5d9ec-be97-44bd-bff0-5742d929c003.json')
          .then((res) => res.json())
          .then((data) => {
            var layer = new mapboxgl.supermap.L7Layer({ type: 'LineLayer' });
            var l7Layer = layer.getL7Layer();
            l7Layer
              .source(data)
              .shape('line')
              .color('highway', (v) => {
                switch (v) {
                  case 'motorway':
                    return '#F9D371';
                  case 'motorway_link':
                    return '#3DB2FF';
                  case 'trunk':
                    return 'green';
                  case 'trunk_link':
                    return '#6E85B2';
                  case 'primary':
                    return '#F47340';
                  case 'primary_link':
                    return '#F6A9A9';
                  case 'secondary':
                    return '#EF2F88';
                  case 'secondary_link':
                    return '#5F7A61';
                  case 'tertiary':
                    return '#1ee3cf';
                  case 'tertiary_link':
                    return '#C2F784';
                  case 'pedestrian':
                    return '#FFF89A';
                  case 'residential':
                    return 'rgba(22, 119, 255, .5)';
                  case 'road':
                    return '#93FFD8';
                  case 'path':
                    return '#BAFFB4';
                  case 'unclassified':
                    return '#D3DEDC';
                  case 'service':
                    return '#AEFEFF';
                  case 'living_street':
                    return '#9B0000';
                  case 'track':
                    return '#F5F5F5';
                  case 'highway':
                    return 'red';
                  case 'rail':
                    return '#08ffc8';
                  default:
                    return '#FFE3E3';
                }
              })
              .animate({
                interval: 1, // 间隔
                duration: 1, // 持续时间，延时
                trailLength: 2 // 流线长度
              });
            map.addLayer(layer);
          });
      });
    </script>
  </body>
</html>
